<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>5 京东秒杀Tab导航高亮</title>
  </head>
  <style>
    ul {
      list-style: none;
      padding: 0;
      margin: 0;
      display: inline-flex;
    }
    li {
      margin-left: 10px;
    }

    a {
      text-decoration: none;
    }
    hr {
      background: red;
      height: 1px;
      border: none;
    }
    .active {
    background: red;
    }
  </style>
  <body>
    <div id="app">
      <ul>
        <li v-for="(item,index) in list" :key="item.id" @click="activeIndex = index">
          <a href="#" :class="{ active: index === activeIndex }">
            {{item.name}}</a
          >
        </li>
      </ul>
      <!-- 横线 -->
      <hr />
    </div>

    <script src="../js/vue.js"></script>
    <script>
      var app = new Vue({
        el: "#app",
        data: {
          activeIndex: 0,
          list: [
            { id: 1, name: "京东秒杀" },
            { id: 2, name: "每日特价" },
            { id: 3, name: "品类秒杀" },
          ],
        },
        methods: {},
      });
    </script>
  </body>
</html>
